\defmodule {ExponentialInverseFromDensityGen}

This class implements \emph{exponential} random variate generators
 using numerical inversion of the \emph{exponential} density
as described in \cite{rDER10a}. It makes use of the class
\externalclass{umontreal.iro.lecuyer.probdist}{InverseDistFromDensity}.
Generating exponential random variables by inversion usually requires
the computation of a logarithm for each generated random number.
Numerical inversion precomputes a set of tables that will speed up the
generation of random variables. This is useful if one 
wants to generate a large number of random variables.


\bigskip\hrule

\begin{code}
\begin{hide}
/*
 * Class:        ExponentialInverseFromDensityGen
 * Description:  exponential random variate generators using numerical
                 inversion of the exponential density
 * Environment:  Java
 * Software:     SSJ 
 * Copyright (C) 2001  Pierre L'Ecuyer and Universite de Montreal
 * Organization: DIRO, Universite de Montreal
 * @author       Richard Simard
 * @since

 * SSJ is free software: you can redistribute it and/or modify it under
 * the terms of the GNU General Public License (GPL) as published by the
 * Free Software Foundation, either version 3 of the License, or
 * any later version.

 * SSJ is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.

 * A copy of the GNU General Public License is available at
   <a href="http://www.gnu.org/licenses">GPL licence site</a>.
 */
\end{hide}
package umontreal.iro.lecuyer.randvar;\begin{hide}
import umontreal.iro.lecuyer.rng.*;
import umontreal.iro.lecuyer.probdist.*;
\end{hide}

public class ExponentialInverseFromDensityGen extends ExponentialGen \begin{hide} {

\end{hide}\end{code}

\subsubsection* {Constructors}
\begin{code}

   public ExponentialInverseFromDensityGen (RandomStream stream,
                                            double lambda,
                                            double ueps, int order) \begin{hide} {
      // dist is the exponential distribution
      super (stream, lambda);
      double xc = Math.min(1.0, 0.5/lambda);

      // Member (ExponentialDist) dist is replaced by 
      // (InverseDistFromDensity) dist
      dist = new InverseDistFromDensity ((ContinuousDistribution) dist,
                                         xc, ueps, order);
    }\end{hide}
\end{code} 
\begin{tabb} Creates an exponential random variate generator with
 parameter $\lambda $ = \texttt{lambda}, using stream \texttt{stream}.
It uses numerical inversion with precomputed tables.
The $u$-resolution \texttt{ueps} is the desired absolute error in the 
\texttt{cdf}, and \texttt{order} is the degree of the Newton interpolating 
polynomial over each interval.
\end{tabb}
\begin{code}

   public ExponentialInverseFromDensityGen (RandomStream stream, 
                                            ExponentialDist dist,
                                            double ueps, int order) \begin{hide} {
      super (stream, dist);
      double xc = Math.min(1.0, 0.5/lambda);

      // Member (ExponentialDist) dist is replaced by 
      // (InverseDistFromDensity) dist
      this.dist = new InverseDistFromDensity (dist, xc, ueps, order);
   } \end{hide}
\end{code}
 \begin{tabb}  Similar to the above constructor, with the exponential 
   distribution \texttt{dist}.  
 \end{tabb}
\begin{code}

   public ExponentialInverseFromDensityGen (RandomStream stream, 
                                            InverseDistFromDensity dist) \begin{hide} {
      super (stream, null);
      lambda = -1;   // don't know its explicit value; it is inside dist
      this.dist = dist;
   } \end{hide}
\end{code}
 \begin{tabb}  Creates a new exponential generator using the \emph{exponential}
   distribution \texttt{dist} and stream \texttt{stream}. \texttt{dist}
   may be obtained by calling method \method{getDistribution}{()},
   after using one of the other constructors to create the 
   precomputed tables. This is useful when one needs many   generators 
 using the same exponential distribution
(same $\lambda$). Precomputing tables for numerical inversion is
 costly; thus using only one set of tables for many generators 
is more efficient. The first \class{ExponentialInverseFromDensityGen} generator 
 using the other constructors creates the precomputed tables.
Then all other streams use this constructor with the same set of tables.
\end{tabb}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%5
\subsubsection* {Methods}
\begin{code}

   public double getUepsilon()\begin{hide} {
      return ((InverseDistFromDensity)dist).getEpsilon();
   }
\end{hide}
\end{code}
\begin{tabb}
   Returns the $u$-resolution \texttt{ueps}.
\end{tabb}
\begin{code}

   public int getOrder()\begin{hide} {
      return ((InverseDistFromDensity)dist).getOrder();
   }
\end{hide}
\end{code}
\begin{tabb}
   Returns the order of the interpolating polynomial.
\end{tabb}

\begin{hide}
\begin{code}
}\end{code}
\end{hide}
